package com.arctan.mhxy_utils_android.utils;

import com.elvishew.xlog.LogLevel;
import com.elvishew.xlog.flattener.Flattener2;
import com.elvishew.xlog.printer.file.naming.FileNameGenerator;

/**
     * LogUtil.java
     * Desc :
     * Create by wangzhiguo
     * Date: 2024/9/13
     */
public class LogUtil {
    /**
     * 日志名称生成类
     */
    public static class  MyLogNameGenerator implements FileNameGenerator{
        @Override
        public boolean isFileNameChangeable() {
            return true;
        }

        @Override
        public String generateFileName(int logLevel, long timestamp) {
            String dateStr=DateUtil.long2Str(timestamp,"yyyyMMdd");
            return "LOG_"+dateStr+".txt";
        }
    }
    public static class  MyGpsNameGenerator implements FileNameGenerator{
        @Override
        public boolean isFileNameChangeable() {
            return true;
        }

        @Override
        public String generateFileName(int logLevel, long timestamp) {
            String dateStr=DateUtil.long2Str(timestamp,"yyyyMMdd");
            return "GPS_"+dateStr+".txt";
        }
    }
    public static class  PhoneGpsNameGenerator implements FileNameGenerator{
        @Override
        public boolean isFileNameChangeable() {
            return true;
        }

        @Override
        public String generateFileName(int logLevel, long timestamp) {
            String dateStr=DateUtil.long2Str(timestamp,"yyyyMMdd");
            return "PHONEGPS_"+dateStr+".txt";
        }
    }
    public  static class MyFlattener implements Flattener2{
        @Override
        public CharSequence flatten(long timeMillis, int logLevel, String tag, String message) {
            return DateUtil.long2Str(timeMillis,"yyyy-MM-dd HH:mm:ss")+"："+message;
        }
    }
}
